package com.leinao.core;


import com.leinao.domain.SysDevicePoint;

import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * description
 *
 * @author zhong.wang
 * @date 2025/1/13
 */
public class DevicePointPool {

    private static final DevicePointPool INSTANCE = new DevicePointPool();
    private Map<Long, List<SysDevicePoint>> fromDevicePointPool;

    private Map<Long,List<SysDevicePoint>> toDevicePointPool;

    private DevicePointPool() {
        fromDevicePointPool = new ConcurrentHashMap<>(100);
        toDevicePointPool = new ConcurrentHashMap<>(100);
    }

    public void registerFromDevicePoint(Long deviceId,List<SysDevicePoint> pointList){
      fromDevicePointPool.putIfAbsent(deviceId, pointList);
    }

    public void registerToDevicePoint(Long deviceId,List<SysDevicePoint> pointList){
        toDevicePointPool.putIfAbsent(deviceId,pointList);
    }

    public List<SysDevicePoint> getPointListFrom(Long deviceId){
        return fromDevicePointPool.get(deviceId);
    }

    public List<SysDevicePoint> getPointListTo(Long deviceId){
        return toDevicePointPool.get(deviceId);
    }

    public static DevicePointPool getInstance() {
        return INSTANCE;
    }
}
